/*************************************************************************
 *
 *   file		: Fly.cs
 *   copyright		: (C) The WCell Team
 *   email		: info@wcell.org
 *   last changed	: $LastChangedDate: 2009-06-12 20:37:34 +0100 (Fri, 12 Jun 2009) $
 *   last author	: $LastChangedBy: dominikseifert $
 *   revision		: $Rev: 965 $
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *************************************************************************/

using WCell.Constants.Spells;
using WCell.RealmServer.Entities;
using WCell.Constants;

namespace WCell.RealmServer.Spells.Auras.Handlers
{
	/// <summary>
	/// Enables flying (mostly triggered through flying rides)
	/// </summary>
	public class FlyHandler : AuraEffectHandler
	{
		protected internal override void CheckInitialize(WorldObject caster, Unit target, ref SpellFailedReason failReason)
		{
			if (target is Character)
			{
				var chr = (Character) target;
				if (!chr.CanFly)
				{
					failReason = SpellFailedReason.NotHere;
				}
			}
		}

		protected internal override void Apply()
		{
			m_aura.Auras.Owner.Flying++;
		}

		protected internal override void Remove(bool cancelled)
		{
			m_aura.Auras.Owner.Flying--;
		}
	}
};
